/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package beans;

import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;

/**
 *
 * @author machine
 */
@Stateless
public class UsuariosFacade extends AbstractFacade<Usuarios> implements UsuariosFacadeLocal {
    @PersistenceContext(unitName = "videosJEE-ejbPU")
    private EntityManager em;

    @Override
    protected EntityManager getEntityManager() {
        return em;
    }

    public UsuariosFacade() {
        super(Usuarios.class);
    }

    @Override
    public List<Usuarios> validarAcceso(String usu, String pass) {
        
        Query q = em.createQuery( "SELECT u FROM Usuarios u WHERE u.usuario = '"+usu+"' AND u.clave = '"+pass+"' " );
        
        
        return q.getResultList(); // or getSingleResult();
        
    }
    
}
